package com.acegear.horizon.domain.models.jpa;

import com.acegear.horizon.domain.models.jpa.convert.ContentPartConverter;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

/**
 * Created by wangsike on 2017/2/6.
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(indexes = @Index(columnList = "postId,userId"))
public class PostComment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column
    private Long commentId;
    @Column
    private Long postId;

    @Column
    private Long userId;

    @Column
    private Long floor;

    @Column
    private Long replyTo;

    @Column
    private Long replyFloor;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = ContentPartConverter.class)
    private List<ContentPart> contents;

    private boolean deleted;

    @CreatedDate
    @Column
    private Long createAt;

    @LastModifiedDate
    @Column
    private Long updateAt;


    public PostComment() {
    }

    public PostComment(Long commentId, Long postId, Long userId, Long floor, Long replyTo, Long replyFloor, List<ContentPart> contents, boolean deleted) {
        this.commentId = commentId;
        this.postId = postId;
        this.userId = userId;
        this.floor = floor;
        this.replyTo = replyTo;
        this.replyFloor = replyFloor;
        this.contents = contents;
        this.deleted = deleted;
    }

    public List<ContentPart> getContents() {
        return contents;
    }

    public void setContents(List<ContentPart> contents) {
        this.contents = contents;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getPostId() {
        return postId;
    }

    public void setPostId(Long postId) {
        this.postId = postId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getFloor() {
        return floor;
    }

    public void setFloor(Long floor) {
        this.floor = floor;
    }

    public Long getReplyTo() {
        return replyTo;
    }

    public void setReplyTo(Long replyTo) {
        this.replyTo = replyTo;
    }

    public Long getReplyFloor() {
        return replyFloor;
    }

    public void setReplyFloor(Long replyFloor) {
        this.replyFloor = replyFloor;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }

    public Long getCommentId() {
        return commentId;
    }

    public void setCommentId(Long commentId) {
        this.commentId = commentId;
    }
}
